
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>
<body>
    密码：<input type="password" class="pwd"><span class="sp"></span>
</body>
<script>
    var pwd =  document.querySelector('.pwd')
    var sp =  document.querySelector('.sp')

    pwd.onblur = function(){
        var inpvel = this.value
        if(inpvel.length>=6 && inpvel.length<=16){
            sp.innerText = '格式正确'
            sp.style = 'color:green'
        }else{
            sp.innerText = '格式不正确'
            sp.style = 'color:red'
        }
    }
</script>
</html>